package com.hml520.dao;

import com.hml520.bean.Account;
import com.hml520.db.DBUtil;

import java.util.ArrayList;
import java.util.List;

public class AccountDao {
    public String get(Account condition) {
        String sql = "select * from T_ACCOUNT where 1=1";

        List<Object> params = new ArrayList<Object>();
        if (condition.getId() != null) {
            sql += " and ID=?";
            params.add(condition.getId());
        }
        if (condition.getUsername() != null) {
            sql += " and USERNAME=?";
            params.add(condition.getUsername());
        }
        if (condition.getOpenId() != null) {
            sql += " and OPEN_ID=?";
            params.add(condition.getOpenId());
        }
        if (condition.getChannel() != null) {
            sql += " and CHANNEL=?";
            params.add(condition.getChannel());
        }
        sql += " limit 1";
        return sql;
    }
}
